package com.glacier.framework.component.dto.response;

/**
 * date 2023-12-22 16:58
 *
 * @author glacier
 * @version 1.0
 */
public enum StatusCode implements Code {
    OK("200", "成功"),
    BAD_REQUEST("400", "请求错误"),
    UNAUTHORIZED("401", "未认证"),
    FORBIDDEN("403", "禁止访问"),
    NOT_FOUND("404", "未找到"),
    NOT_SUPPORTED("405", "请求不支持"),
    TIMEOUT("408", "超时"),
    INTERNAL_SERVER_ERROR("500", "服务器内部错误，无法完成请求"),
    BAD_GATEWAY("502", "Bad Gateway"),
    GATEWAY_TIMEOUT("504", "网关超时"),
    NULL_POINTER_EXCEPTION("600", "空指针异常"),
    PARAM_ERROR("601", "参数错误"),

    SERVICE_THROTTLING("1001", "服务限流了"),
    SERVICE_DEGRADATION("1002", "服务降级了"),
    THE_HOTSPOT_PARAMETER_THROTTLES("1003", "热点参数限流了"),
    SYSTEM_PROTECTION("1004", "触发系统保护了"),
    AUTHORIZATION_RULE_IS_NOT_PASSED("1005", "授权规则不通过"),

    ;

    private final String code;
    private final String message;

    StatusCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public static boolean isSuccess(String code) {
        return OK.getCode().equals(code);
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
